package com.crm.controller;


import com.crm.pojo.common.Result;
import com.crm.pojo.dto.LoginDto;
import com.crm.pojo.vo.CaptchaVo;
import com.crm.pojo.vo.LoginVo;
import com.crm.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.UUID;

@RestController
@RequestMapping
@Slf4j
public class LoginController {
    @Autowired
    private LoginService loginService;
    //获取验证码
    //测试
    @GetMapping("/captchaImage")
    public CaptchaVo captchaImage() {

        CaptchaVo captchaVo = new CaptchaVo();
        captchaVo.setImg("");
        captchaVo.setMsg("操作成功");
        captchaVo.setCode(200);
        captchaVo.setUuid(UUID.randomUUID().toString().replace("-", ""));
        return captchaVo;
    }
    //登录
    @PostMapping("/login")
    public LoginVo login(@RequestBody LoginDto loginDto){
        LoginVo login = loginService.login(loginDto);
        return login;
    }

    //退出
    @PostMapping("/logout")
    public Result logout(){return Result.success();}
}
